package com.wzy.vx.config;

import com.lly835.bestpay.config.WxPayH5Config;
import com.lly835.bestpay.service.impl.BestPayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @ProjectName: vx
 * @Package: com.wzy.vx.config
 * @ClassName: WechatPayConfig
 * @Author: Administrator
 * @Description: ${description}
 * @Date: 2019/3/18 9:58
 * @Version: 1.0
 */
@Component
public class WechatPayConfig {
    @Autowired
    private  WechatUserConfig wechatUserConfig;

    @Bean
    public BestPayServiceImpl bestPayService() {
        BestPayServiceImpl bestPayService = new BestPayServiceImpl();
        bestPayService.setWxPayH5Config(wxPayH5Config());
        return bestPayService;
    }

    //H5支付页面配置
    @Bean
    public WxPayH5Config wxPayH5Config() {
        WxPayH5Config wxPayH5Config = new WxPayH5Config();
        wxPayH5Config.setAppId(wechatUserConfig.getMpAppId());
        wxPayH5Config.setAppSecret(wechatUserConfig.getMpAppSecret());
        wxPayH5Config.setMchId(wechatUserConfig.getMchId());
        wxPayH5Config.setMchKey(wechatUserConfig.getMchKey());
        wxPayH5Config.setKeyPath(wechatUserConfig.getKeyPath());
        wxPayH5Config.setNotifyUrl(wechatUserConfig.getNotifyUrl());
        return wxPayH5Config;
    }
}
